#include<bits/stdc++.h>
using namespace std;

void solve() {
    int m, s;
    cin >> m >> s;
    string minn, maxn;
    bool possible = true;

    if (s == 0) {
        if (m == 1) {
            minn = maxn = "0";
        } else {
            possible = false;
        }
    } else {
        if (s > 9 * m) {
            possible = false;
        } else {
            // 构造最大数
            int sum_left = s;
            for (int i = 0; i < m; ++i) {
                int digit = min(9, sum_left);
                maxn += '0' + digit;
                sum_left -= digit;
            }

            // 构造最小数
            sum_left = s;
            for (int i = 0; i < m; ++i) {
                int lower = (i == 0) ? 1 : 0;
                for (int d = lower; d <= 9; ++d) {
                    if (sum_left - d >= 0 && (sum_left - d) <= 9 * (m - i - 1)) {
                        minn += '0' + d;
                        sum_left -= d;
                        break;
                    }
                }
            }
        }
    }

    if (!possible) {
        cout << "-1" << endl;
    } else {
        cout << minn << " " << maxn << endl;
    }
}

int main() {
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}